/**
 * @description Jwt的颁发予校验
 * @author 盘古他爹
 */

// const Jwt = require("jsonwebtoken")
import * as Jwt from "jsonwebtoken"
const secret = "lanshi324"



class _JWT {
    JwtSign(userInfo: object) {
        const token = Jwt.sign(userInfo, secret);
        return token
    }
    JwtVerify(token: string) {
        // console.log("验证", Jwt.verify(token, secret));
        try {
            return Jwt.verify(token, secret);
        } catch(err) {
            console.log("jwt失败:", err);
            return false
            
        }
        

    }
}

const JWT = new _JWT()

export {
    JWT
}

